﻿
$(document).ready(function () {
    // $("input#txtEmission").numeric();
    $("span#vldEmission").hide();

    $("input#btnTAOK").click(function () {
        if (!validateAmount_60pt($("input#txtEmission"))) {
            $("span#vldEmission").show();
            return;
        }
        else {
            $("span#vldEmission").hide();
        }

        processIF();
        $.fancybox.close();
    });

    $("input#btnTACancel").click(function () {
        $.fancybox.close();
    });
});

function resetIFModal() {
    $("select#ddlIFFlows option:eq(0)").prop('selected', 'selected');
    $("input#txtEmission").val('');
    $("select#ddlReference option:eq(0)").prop('selected', 'selected');
}

function loadIFModal(selectedRow) {
    $("select#ddlIFFlows").val(selectedRow.item_id);
    $("input#txtEmission").val(selectedRow.emission);
    $("select#ddlReference").val(selectedRow.ref_id);
}


function processIF() {
    var item_id = $("select#ddlIFFlows").val();
    var item_name = $("select#ddlIFFlows option:selected").text();

    var emission = $("input#txtEmission").val();

    var ref_id = $("select#ddlReference").val();
    var ref_name = $("select#ddlReference option:selected").text();
    if (ref_name == '-- Please Select --')
        ref_name = '';

    var row = {
        item_id: item_id,
        item_name: item_name,
        emission: emission,
        ref_id: ref_id,
        ref_name: ref_name
    };

    callbackFromIFModal(row);
}